Skip to content

feat: update address types dynamically#48

Merged
ovitrif merged 2 commits intomainfrom
feat/dynamic-address-types
Feb 18, 2026
Merged

feat: update address types dynamically#48
ovitrif merged 2 commits intomainfrom
feat/dynamic-address-types

Conversation

@ben-kaufman
Copy link

Summary

Adds runtime APIs to add/remove monitored address types and to change the primary address type without rebuilding the node. Previously, address_type and address_types_to_monitor were fixed at build time via Config.

Changes

Node API

  • add_address_type_to_monitor(address_type, seed_bytes) / add_address_type_to_monitor_with_mnemonic(...) — Add an address type to the monitored set. The wallet is created from the given seed (or loaded from kv-store if previously monitored) and included in subsequent sync cycles. Fails with AddressTypeAlreadyMonitored or AddressTypeIsPrimary when invalid.
  • remove_address_type_from_monitor(address_type) — Remove an address type from monitoring and unload its wallet. Persisted state remains in the kv-store; re-adding the type recovers funds on the next sync. Fails with AddressTypeNotMonitored or AddressTypeIsPrimary when invalid.
  • set_primary_address_type(address_type, seed_bytes) / set_primary_address_type_with_mnemonic(...) — Change the primary address type used for new addresses and change outputs. The previous primary is demoted to the monitored set. If the new primary has never been synced, the next sync performs a full scan.

Implementation

  • AddressTypeRuntimeConfig — New runtime struct (primary + monitored list) initialized from Config and updated by the new APIs. Esplora and Electrum chain sources now take and use this for collect_additional_sync_requests, so sync reflects the current set of address types.
  • Wallet — New operation_lock to serialize add/remove/set_primary; holds kv_store, address_type_runtime_config, and node_metrics. Shared helper create_wallet_for_address_type builds a wallet from seed and attaches it at the current best block.
  • bdk-wallet-aggregate — New methods: add_wallet, set_primary, remove_wallet; new errors: WalletAlreadyExists, CannotRemovePrimary (and existing WalletNotFound).

@ovitrif ovitrif changed the title Update address types dynamically feat: Update address types dynamically Feb 18, 2026
@ovitrif ovitrif changed the title feat: Update address types dynamically feat: update address types dynamically Feb 18, 2026
Copy link
Collaborator

@ovitrif ovitrif left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utAck

Looks solid, code is clean and free of irrelevant adds, tests are solid IMO, read nice and cover the updates.

Will test in iOS 👏🏻

:shipit:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments